home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / batutl2.zip / SETERROR.ASM < prev    next >
Assembly Source File  |  1988-04-20  |  1KB  |  65 lines

  1. TITLE    SETERROR    4-26-84    [4-16-88]
  2. ;Toad Hall Disassembly, tweak
  3.  
  4. LF    EQU    0AH
  5. CR    EQU    0DH
  6. ;
  7. ;INITIAL VALUES :    CS:IP    0000:0100
  8. ;            SS:SP    0000:FFFF
  9. CodeSeg    SEGMENT
  10.     ASSUME DS:CodeSeg,SS:CodeSeg,CS:CodeSeg,ES:CodeSeg
  11.     ORG    100H
  12.  
  13. SetError    proc    near
  14.     MOV    AH,30H            ;get DOS version
  15.     INT    21H
  16.     or    al,al            ;0 means <2.0
  17.     je    BadDOS_Exit        ; bad, error msg, exit
  18.  
  19.     MOV    SI,80H            ;PSP cmd line ptr
  20.     cld                ;insure fwd
  21.     lodsb                ;snarf cmd line length
  22.     CMP    al,2            ;2 chars (includes space)
  23.     jne    Usage_Exit        ; bad, exit w/help msg
  24.  
  25.     lodsb                ;snarf cmd line char
  26.     CMP    al,' '            ;space?
  27.     jne    Usage_Exit        ; nope, bad, exit w/help msg
  28.  
  29.     lodsb                ;snarf cmd line char
  30.     CMP    al,'0'            ;>= 0?
  31.     jb    Usage_Exit        ;illegal, exit w/help msg
  32.     CMP    al,'9'            ;<= 9?
  33.     ja    Usage_Exit        ;illegal, exit w/help msg
  34.  
  35.     SUB    al,30H            ;deAsciify as Errorlevel
  36.     MOV    AH,4CH            ;terminate
  37.     INT    21H
  38.  
  39. BadDOS_Exit:
  40.     mov    DX,offset DOSmsg    ;'requires DOS 2.0...'
  41.     MOV    AH,9            ;display string
  42.     INT    21H
  43.     XOR    AX,AX            ;terminate
  44.     INT    21H
  45.  
  46. Usage_Exit:
  47.     mov    DX,offset helpmsg
  48.     MOV    AH,9            ;display string
  49.     INT    21H
  50.     MOV    AX,4C00H        ;terminate, Errorlevel 0
  51.     INT    21H
  52.  
  53. DOSmsg    DB    'SETERROR requires DOS 2.0 or greater.',CR,LF,'$'
  54. helpmsg    DB    'SETERROR -- sets the DOS ERRORLEVEL for batch file processing'
  55.     db    CR,LF
  56.     DB    'Usage:',CR,LF
  57.     DB    '      SETERROR n',CR,LF
  58.     DB    'where n is between 0 and 9.',CR,LF,'$'
  59.  
  60. ;    DB    'SETERROR -- Copyright (C) 1983 Tony Alan Rhea'
  61. SetError    endp
  62.  
  63. CodeSeg    ENDS
  64.     END    SetError
  65.